/**
 * Copyright (C) 2025 pony working team
 * SPDX-License-Identifier: MulanPSL-2.0
 */

/* define to prevent recursive inclusion -------------------------------------*/
#ifndef __PONY_X_SYSCALL_H__
#define __PONY_X_SYSCALL_H__

/* includes (standard library, system) ---------------------------------------*/
/* includes (other library) --------------------------------------------------*/
/* includes (project) --------------------------------------------------------*/
#include <x_errno.h>
/* includes (local) ----------------------------------------------------------*/

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/* defines -------------------------------------------------------------------*/

#define SYSNUM_DEF(mid, rid)   (((mid & 255) << 8) | (rid & 255))
#define SYSNUM_GET_MID(sysnum) (sysnum >> 8)
#define SYSNUM_GET_RID(sysnum) (sysnum & 255)

#define ERRNO_SYSCALL_ILLEGAL_MID ERRNO_JOIN(MID_SYSCALL, 1)
#define ERRNO_SYSCALL_ILLEGAL_RID ERRNO_JOIN(MID_SYSCALL, 2)

/* typedefs ------------------------------------------------------------------*/

typedef unsigned int syscall_id;

struct syscall_table {
    unsigned int nr_entries;
    const uintptr_t *entries;
};

/* macro ---------------------------------------------------------------------*/
/* inlines -------------------------------------------------------------------*/
/* externs -------------------------------------------------------------------*/

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* __PONY_X_SYSCALL_H__ */
